﻿

namespace Cuce.ReportingServices.MSBuild.UnitTests
{
    using ReportingServices.UnitTests.Mock;
    using System;
    using NUnit.Framework;

    /// <summary>
    /// 
    /// </summary>
    [TestFixture]
    public class DeleteReportTest
    {

        private DeleteReport i;
        private const string validFolder = "/testFolder/";
        private const string validName = "testName";
        private const string validURL = "testUrl";

        /// <summary>
        /// Somes the test.
        /// </summary>
        [Test]
        public void WorkingTest()
        {
            i = new DeleteReport(new ReportingServicesMock()) { Url = validURL, Name = validName, Folder = validFolder };

            Assert.IsTrue(i.Execute());
        }

        /// <summary>
        /// Reportings the services Delete no RS.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServicesDeleteNoRS()
        {
            i = new DeleteReport(null) { Name = validName, Folder = validFolder };

            Assert.IsTrue(i.Execute());
        }

        /// <summary>
        /// Reportings the services Delete no URL.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServicesDeleteNoUrl()
        {
            i = new DeleteReport(new ReportingServicesMock()) { Name = validName, Folder = validFolder };

            Assert.IsTrue(i.Execute());
        }

        /// <summary>
        /// Reportings the name of the services Delete no.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServicesDeleteNoName()
        {
            i = new DeleteReport(new ReportingServicesMock()) { Url = validURL, Folder = validFolder };

            Assert.IsTrue(i.Execute());
        }

        /// <summary>
        /// Reportings the services Delete no folder.
        /// </summary>
        [Test]
        [ExpectedException(typeof(ArgumentException))]
        public void ReportingServicesDeleteNoFolder()
        {
            i = new DeleteReport(new ReportingServicesMock()) { Url = validURL, Name = validName };

           
          
            Assert.IsTrue(i.Execute());
        }


        /// <summary>
        /// Reportings the services Delete with creditials.
        /// </summary>
        [Test]
        public void ReportingServicesDeleteWithCreditials()
        {
             i = new DeleteReport(new ReportingServicesMock())
                     {
                         Url = validURL,
                         Name = validName,
                         Folder = validFolder,
                         CredentialsDomain = "test",
                         CredentialsUserName = "test",
                         CredentialsPassword = "test"
                     };


            Assert.IsTrue(i.Execute());
        }

        /// <summary>
        /// Reportings the services Delete with proxy.
        /// </summary>
        [Test]
        public void ReportingServicesDeleteWithProxy()
        {
             i = new DeleteReport(new ReportingServicesMock())
                     {
                         Url = validURL,
                         Name = validName,
                         Folder = validFolder,
                         Proxy = true
                     };


            Assert.IsTrue(i.Execute());
        }

        

        /// <summary>
        /// Reportings the services Delete with error.
        /// </summary>
        [Test]
        public void ReportingServicesDeleteWithError()
        {
            i = new DeleteReport(new ReportingServicesMock()) { Url = validURL, Name = "error", Folder = validFolder };


            Assert.IsFalse(i.Execute());
        }

        /// <summary>
        /// Reportings the services Delete with warning.
        /// </summary>
        [Test]
        public void ReportingServicesDeleteWithWarning()
        {
            i = new DeleteReport(new ReportingServicesMock()) { Url = validURL, Name = "warning", Folder = validFolder };


            Assert.IsFalse(i.Execute());
        }
    }
}
